home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
...taking it to the Macs!
/
...taking it to the Macs!.iso
/
Extras
/
ActiveX Mac SDK
/
ActiveX SDK
/
Control Common
/
CEnumConnections.cpp
< prev
next >
Wrap
Text File
|
1996-10-17
|
3KB
|
168 lines
//
#include "ocheaders.h"
#include <LArray.h>
#include "CEnumConnections.h"
//
// CEnumConnections::CEnumConnections
//
CEnumConnections::CEnumConnections(LArray* ConnectArray)
{
unsigned long i;
CONNECTDATA ConnectData;
m_RefCount = 0;
m_Current = 1;
m_ConnectArray = ConnectArray;
// AddRef all the unknowns in this connect data
for ( i = 1; i <= m_ConnectArray->GetCount(); i ++ )
{
m_ConnectArray->FetchItemAt(i, &ConnectData);
ConnectData.pUnk->AddRef();
}
}
//
// CEnumConnections::~CEnumConnections
//
CEnumConnections::~CEnumConnections(void)
{
if ( m_ConnectArray )
{
unsigned long i;
CONNECTDATA* ConnectData;
for ( i = 1; i <= m_ConnectArray->GetCount(); i ++ )
{
ConnectData = (CONNECTDATA*) m_ConnectArray->GetItemPtr(i);
ConnectData->pUnk->Release();
}
delete m_ConnectArray;
}
}
//
// CEnumConnections::IUnknown::QueryInterface
//
// Returns a pointer to the specified interface on a component to which a
// client currently holds an interface pointer.
//
STDMETHODIMP
CEnumConnections::QueryInterface(REFIID RefID, void** Obj)
{
void* pv;
if (RefID == IID_IUnknown)
pv = (void*) this;
else if (RefID == IID_IEnumConnections )
pv = (void*)(IEnumConnections*) this;
else {
*Obj = NULL;
return ResultFromScode(E_NOINTERFACE);
}
*Obj = pv;
((IUnknown*) pv)->AddRef();
return ResultFromScode(S_OK);
}
//
// CEnumConnections::IUnknown::AddRef
//
// Increments the reference count for the calling interface.
//
STDMETHODIMP_(ULONG)
CEnumConnections::AddRef(void)
{
return ++m_RefCount;
}
//
// CEnumConnections::IUnknown::Release
//
// Decrements the reference count for the calling interface on a object. If
// the reference count on the object falls to zero, the object is freed.
//
STDMETHODIMP_(ULONG)
CEnumConnections::Release(void)
{
if (--m_RefCount != 0)
return m_RefCount;
delete this;
return 0;
}
//
// CEnumConnections::IEnumConnections::Next
//
STDMETHODIMP
CEnumConnections::Next(unsigned long NumRequested,
CONNECTDATA* ConnectData,
unsigned long* NumReturned)
{
unsigned long Returned = 0;
unsigned long RemainingRequests = NumRequested;
while ( m_Current <= m_ConnectArray->GetCount() && RemainingRequests > 0 )
{
// Copy the item to the CONNECTDATA and addref
m_ConnectArray->FetchItemAt(m_Current, ConnectData);
ConnectData->pUnk->AddRef();
// Move to the next item in the given CONNECTDATA array
ConnectData++;
// One more returned, one less requested
Returned ++;
RemainingRequests --;
// Next item please
m_Current++;
}
// if the client is interested, pass this info back
if ( NumReturned )
(*NumReturned) = Returned;
// Set the correct return value
if ( Returned == NumRequested )
return ResultFromScode(S_OK);
else
return ResultFromScode(S_FALSE);
}
//
// CEnumConnections::IEnumConnections::Skip
//
STDMETHODIMP
CEnumConnections::Skip(unsigned long NumSkip)
{
#pragma unused (NumSkip)
return E_NOTIMPL;
}
//
// CEnumConnections::IEnumConnections::Clone
//
STDMETHODIMP
CEnumConnections::Clone(IEnumConnections** Enum)
{
#pragma unused (Enum)
return E_NOTIMPL;
}